<template>
	<view class="page">
		<view class="page-ctx">
			<view class="record-list">
				<view class="record-item" v-for="(item,index) in records" :key="index">
					<view class="ques-title ">
						<view class="letter">
							Q
						</view>
						<view class="title">
							{{item.title || ''}}
						</view>
					</view>
					<view class="ques-content ">
						<view class="letter">
							A
						</view>
						<view class="desc">
							<view class="html-box">
								<u-parse :content="item.description" :tagStyle="richStyle"></u-parse>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>

		<w_bottom_safe height="40" />
	</view>
</template>

<script>
	export default {
		components: {

		},
		data() {
			return {
				records: [],
				count: 0,
				pagination: {
					page: 1,
					pageNum: 10
				},
				loadmore_status: 'loadmore', //loadmore  / loading / nomore
				//
				richStyle: {
					// 字符串的形式
					p: 'color: #000000;font-size: 12px;line-height:1.6;font-family: PingFangSC-Regular;text-align:justify;',
					span: 'color: #000000;font-size: 12px;line-height:1.6;font-family: PingFangSC-Regular;',
					img: 'vertical-align: bottom;'
				},

			};
		},
		onLoad() {
			this.setView();
		},
		onReachBottom() {
			this.loadMore()
		},
		methods: {
			loadMore() {
				if (this.loadmore_status == 'loadmore') {
					this.loadmore_status = 'loading'
					this.pagination.page++;
					this.query_records();
				}
			},
			initQuery() {
				this.records = [];
				this.pagination.page = 1;
				this.loadmore_status = 'loadmore'
			},
			setView() {
				this.query_records()
			},
			query_records() {
				this.$api({
					url: '/service.php',
					method: 'get',
					data: {
						action: 'news_lists',
						channelId: 44,
						...this.pagination,
						// isIndex: 0,
					},
				}).then(res => {
					if (res.code == 200) {
						this.count = res.data.count;
						let list = res.data.list;
						this.records = this.records.concat(list);
						this.loadmore_status = this.count > this.records.length ? 'loadmore' : 'nomore';
					}
				})
			},
		}
	}
</script>

<style>
	page {
		background: #FFFFFF;
	}
</style>
<style lang="scss">
	.page {
		.page-ctx {
			padding: 24rpx 32rpx;
		}
	}

	.record-list {
		.record-item {
			margin-bottom: 24rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 16rpx 2rpx rgba(0, 0, 0, 0.08);
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			padding: 32rpx 24rpx;
			background: #fff;

			.ques-title {
				display: flex;
				align-items: flex-start;

				.letter {
					width: 48rpx;
					text-align: left;
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					font-size: 32rpx;
					color: #282D43;
				}

				.title {
					flex: 1;
					overflow: hidden;

					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 32rpx;
					color: #000000;
				}
			}

			.ques-content {
				margin-top: 20rpx;
				display: flex;
				align-items: flex-start;

				.letter {
					text-align: left;
					width: 48rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					font-size: 24rpx;
					color: #CB0011;
				}

				.desc {
					flex: 1;
					overflow: hidden;

					.html-box {
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #000000;
						line-height: 1.5;
					}
				}
			}
		}
	}
</style>